package com.drama.api.sys.order.service.impl;

import cn.hutool.core.date.DateUtil;
import com.drama.api.company.order.domain.vo.CompanyOrderCountVO;
import com.drama.api.sys.order.dao.OrderRechargeDao;
import com.drama.api.sys.order.domain.vo.*;
import com.drama.api.sys.order.service.IOrderRechargeService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;


@Service
@Transactional
@Slf4j
public class OrderRechargeServiceImpl implements IOrderRechargeService {

    @Autowired
    private OrderRechargeDao rechargeDao;

    @Override
    public CompanyOrderCountVO getCount() {
        CompanyOrderCountVO countVO=new CompanyOrderCountVO();
        SysOrderRechargeCountSearchVO searchVO=new SysOrderRechargeCountSearchVO();
        //查询总统计
        countVO.setTotalNum(rechargeDao.getCount(searchVO));
        //查询当日统计
        searchVO.setStartDate(DateUtil.beginOfDay(DateUtil.yesterday()).toString());
        searchVO.setEndDate(DateUtil.endOfDay(DateUtil.yesterday()).toString());
        countVO.setYesterdayNum(rechargeDao.getCount(searchVO));
        //查询当月统计
        searchVO.setStartDate(DateUtil.beginOfMonth(DateUtil.date()).toString());
        searchVO.setEndDate(DateUtil.endOfMonth(DateUtil.date()).toString());
        countVO.setThisMonthNum(rechargeDao.getCount(searchVO));
        return countVO;
    }

    @Override
    public List<SysOrderRechargeListVO> getCountList(SysOrderRechargeSearchVO searchVO) {
        return rechargeDao.getCountList(searchVO);
    }

    @Override
    public SysOrderRechargeListVO getCountListTotal(SysOrderRechargeListTotalVO searchVO) {
        return rechargeDao.getCountListTotal(searchVO);
    }

    @Override
    public List<SysOrderRechargeVO> getList(SysOrderRechargeSearchVO searchVO) {
        return rechargeDao.getList(searchVO);
    }
}